//
//  DetailsCollectionViewCell.m
//  futureLive
//
//  Created by zhoubiwen on 15/11/17.
//  Copyright © 2015年 ZHOU_LI_SUN. All rights reserved.
//

#import "DetailsCollectionViewCell.h"
#import <UIImageView+WebCache.h>
@interface DetailsCollectionViewCell ()

@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *productNameLabel;
@property (nonatomic, strong) UILabel *priceLabel;
@property (nonatomic, strong) UILabel *origPriceLabel;
@property (nonatomic, strong) UIButton *button;

@end
@implementation DetailsCollectionViewCell

-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        [self setupSubViews];
    }
    
    return self;
}

-(void)setupSubViews{
    
    self.imageView                        = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, self.frame.size.width - 20, self.frame.size.height - 120)];
    [self.contentView addSubview:self.imageView];

    self.productNameLabel                 = [[UILabel alloc] initWithFrame:CGRectMake(10, self.frame.size.height - 100, self.frame.size.width - 15, 50)];
    self.productNameLabel.backgroundColor = [UIColor yellowColor];

    [self.contentView addSubview:self.productNameLabel];


    self.origPriceLabel                   = [[UILabel alloc] initWithFrame:CGRectMake(10, self.frame.size.height - 50, self.frame.size.width - self.frame.size.width / 2 - 10, 25)];

    self.origPriceLabel.backgroundColor   = [UIColor redColor];

    [self.contentView addSubview:self.origPriceLabel];



    self.priceLabel                       = [[UILabel alloc] initWithFrame:CGRectMake(10, self.frame.size.height - 30, self.frame.size.width - self.frame.size.width / 2 - 10, 25)];

    self.priceLabel.backgroundColor       = [UIColor greenColor];

    [self.contentView addSubview:self.priceLabel];

    self.button                           = [UIButton buttonWithType:UIButtonTypeSystem];
    self.button.frame                     = CGRectMake(self.frame.size.width - self.frame.size.width / 2 - 10, self.frame.size.height - 50, self.frame.size.width - self.frame.size.width / 2, 50);
    self.button.backgroundColor           = [UIColor blueColor];
    [self.button setImage:[UIImage imageNamed:@"iconfont-shouye"] forState:UIControlStateNormal];
    
    [self.contentView addSubview:self.button];
}


#pragma mark ---- 重写setter方法
-(void)setDetailsModel:(DetailsModel *)detailsModel{
    if (_detailsModel != detailsModel) {
        _detailsModel = nil;
        _detailsModel = detailsModel;
        [self layoutModel];
    }
}
-(void)layoutModel{
    
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:_detailsModel.imageUrl]];
    self.priceLabel.text = _detailsModel.price;
    self.productNameLabel.text = _detailsModel.productName;
    
}






@end
